﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class Contacts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void SendButton_Click(object sender, EventArgs e)
    {
        try
        {
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress(Email.Text, FullName.Text);
            System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings["Email_Support"]);
            System.Net.Mail.MailMessage message =
                new System.Net.Mail.MailMessage(fromAddress, toAddress);
            message.Subject = ConfigurationManager.AppSettings["Contacts_Email_Subject"];
            message.Body = Message.Text;
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Send(message);
            MessageSendStatus.Text = string.Format("<p style='color:green'><b>{0}</b></p>", this.GetLocalResourceObject("MessageSend.Successful"));
            ClearForm();
        }
        catch (Exception)
        {
            MessageSendStatus.Text = string.Format("<p style='color:red'><b>{0}</b></p>", this.GetLocalResourceObject("MessageSend.Failed"));
            BLL.Log.SendError();
        }

    }

    private void ClearForm()
    {
        Email.Text = string.Empty;
        FullName.Text = string.Empty;
        Message.Text = string.Empty;
    }
}
